import { IPSDEUIAppendParamLogic } from './ipsdeuiappend-param-logic';
import { IPSDEUILogic } from './ipsdeuilogic';
import { IPSDEUILogicParam } from './ipsdeuilogic-param';
import { PSDEUILogicNodeImpl } from './psdeuilogic-node-impl';

export class PSDEUIAppendParamLogicImpl extends PSDEUILogicNodeImpl implements IPSDEUIAppendParamLogic {
  get dstIndex(): number {
    return this.M.dstIndex != null ? this.M.dstIndex : -1;
  }

  protected dstpsdeuilogicparam: IPSDEUILogicParam | null = null;

  getDstPSDEUILogicParam(): IPSDEUILogicParam | null {
    if (this.dstpsdeuilogicparam != null) return this.dstpsdeuilogicparam;
    const value = this.M.getDstPSDEUILogicParam;
    if (value == null) {
      return null;
    }
    const ipsdeuilogic = this.getParentPSModelObject('dataentity.logic.IPSDEUILogic') as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.dstpsdeuilogicparam = ipsdeuilogic.findPSDEUILogicParam(value);
    }
    return this.dstpsdeuilogicparam;
  }

  get dstPSDEUILogicParam(): IPSDEUILogicParam | null {
    return this.getDstPSDEUILogicParam();
  }

  getDstPSDEUILogicParamMust(): IPSDEUILogicParam {
    const value = this.getDstPSDEUILogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  get srcFieldName(): string {
    return this.M.srcFieldName;
  }

  get srcIndex(): number {
    return this.M.srcIndex != null ? this.M.srcIndex : -1;
  }

  protected srcpsdeuilogicparam: IPSDEUILogicParam | null = null;

  getSrcPSDEUILogicParam(): IPSDEUILogicParam | null {
    if (this.srcpsdeuilogicparam != null) return this.srcpsdeuilogicparam;
    const value = this.M.getSrcPSDEUILogicParam;
    if (value == null) {
      return null;
    }
    const ipsdeuilogic = this.getParentPSModelObject('dataentity.logic.IPSDEUILogic') as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.srcpsdeuilogicparam = ipsdeuilogic.findPSDEUILogicParam(value);
    }
    return this.srcpsdeuilogicparam;
  }

  get srcPSDEUILogicParam(): IPSDEUILogicParam | null {
    return this.getSrcPSDEUILogicParam();
  }

  getSrcPSDEUILogicParamMust(): IPSDEUILogicParam {
    const value = this.getSrcPSDEUILogicParam();
    if (value == null) {
      throw new Error('未指定源逻辑参数对象');
    }
    return value;
  }

  get srcSize(): number {
    return this.M.srcSize != null ? this.M.srcSize : -1;
  }

  get cls(): string {
    return 'PSDEUIAppendParamLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDEUIAppendParamLogic') return true;
    return super.instanceof(cls);
  }
}
